import { Post } from '../../config.js'

class Api {
  /**
   * 开通城市运费列表
   * @param {object} params 参数对象
   * @desc {string} acc_id 身份验证参数,登陆时返回
   * @desc {string} page 页码
   * @desc {string} page_size 每页个数
   * @desc {string} search 查询数据
   * @desc {string} sort_field 排序字段
   * @desc {string} sort_type 0正序
   * @return {promise} api
   */
  freightList (params) {
    const data = {
      Copyright: 'v1',
      Interface: 'Freight',
      Command: 'freightList',
      Params: params
    }
    return Post(data)
  }
  /**
   * 获取省列表
   * @param {object} params 参数对象
   * @desc {string} acc_id 身份验证参数,登陆时返回
   * @return {promise} api
   */
  getAllProvince (params) {
    const data = {
      Copyright: 'v1',
      Interface: 'Freight',
      Command: 'getAllProvince',
      Params: params
    }
    return Post(data)
  }
  /**
   * 获取市区列表
   * @param {object} params 参数对象
   * @desc {string} acc_id 身份验证参数,登陆时返回
   * @desc {string} id 所选省市的ID
   * @return {promise} api
   */
  getCityAreaById (params) {
    const data = {
      Copyright: 'v1',
      Interface: 'Freight',
      Command: 'getCityAreaById',
      Params: params
    }
    return Post(data)
  }
  /**
   * 添加新的地区运费
   * @param {object} params 参数对象
   * @desc {string} acc_id 身份验证参数,登陆时返回
   * @desc {string} p_id 省ID
   * @desc {string} c_id 市ID
   * @desc {string} price 运费价格
   * @return {promise} api
   */
  addFreight (params) {
    const data = {
      Copyright: 'v1',
      Interface: 'Freight',
      Command: 'addFreight',
      Params: params
    }
    return Post(data)
  }
  /**
   * 修改地区运费
   * @param {object} params 参数对象
   * @desc {string} acc_id 身份验证参数,登陆时返回
   * @desc {string} id 地区ID
   * @desc {string} p_id 省ID
   * @desc {string} c_id 市ID
   * @desc {string} price 运费价格
   * @return {promise} api
   */
  alertFreight (params) {
    const data = {
      Copyright: 'v1',
      Interface: 'Freight',
      Command: 'alertFreight',
      Params: params
    }
    return Post(data)
  }
  /**
   * 修改地区运费
   * @param {object} params 参数对象
   * @desc {string} acc_id 身份验证参数,登陆时返回
   * @desc {string} id 地区ID
   * @desc {string} p_id 省ID
   * @desc {string} c_id 市ID
   * @desc {string} price 运费价格
   * @return {promise} api
   */
  updateFreight (params) {
    const data = {
      Copyright: 'v1',
      Interface: 'Freight',
      Command: 'updateFreight',
      Params: params
    }
    return Post(data)
  }
  /**
   * 删除地区运费
   * @param {object} params 参数对象
   * @desc {string} acc_id 身份验证参数,登陆时返回
   * @desc {string} id 地区ID
   * @return {promise} api
   */
  delFreightById (params) {
    const data = {
      Copyright: 'v1',
      Interface: 'Freight',
      Command: 'delFreightById',
      Params: params
    }
    return Post(data)
  }
}

const ShaohuoPriceService = new Api()
export default ShaohuoPriceService
